<template>
  <div>
    <div
      v-if="previewStatus"
      class="warp-wapper"
      v-html="formRow.row[field.id].replace(/(\n)/g, '<br />')"
    />
    <el-input
      v-else
      ref="fieldEditor"
      v-model="formRow.row[field.id]"
      type="textarea"
      :disabled="field.options.disabled"
      :readonly="field.options.readonly"
      :size="field.options.size"
      :placeholder="field.options.placeholder"
      :autosize="
        field.options.autosize ? { minRows: field.options.rows } : false
      "
      :rows="field.options.rows"
      :minlength="field.options.minLength"
      :maxlength="field.options.maxLength"
      :show-word-limit="field.options.showWordLimit"
    />
  </div>
</template>

<script>
/* eslint-disable vue/require-default-prop */
/* eslint-disable eol-last */

import tableMixin from "./tableMixin";

export default {
  name: "table_textarea_unit",
  componentName: "FieldWidget",
  mixins: [tableMixin],
  props: {
    designer: Object,
    field: Object,
    formRow: Object,
    formData: Object,
    designState: {
      type: Boolean,
      default: false,
    },
  },
  // inject: ["refList", "formConfig", "globalOptionData", "globalModel"],
  data() {
    return {
      oldFieldValue: null,
      rules: [],
    };
  },
  beforeCreate() {
    /* 这里不能访问方法和属性！！ */
  },
  created() {
    /* 注意：子组件mounted在父组件created之后、父组件mounted之前触发，故子组件mounted需要用到的prop
         需要在父组件created中初始化！！ */
    // this.initFieldModel();
    // this.registerToRefList();
    // this.buildFieldRules();
    this.handleOnCreated();
  },
  mounted() {
    // console.log(this.formRow.row);
    this.initEventHandler();
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
@import "../../../../../../styles/global.scss"; //* form-item-wrapper已引入，还需要重复引入吗？ *//
.warp-wapper {
  display: block;
  white-space: normal;
  word-break: break-all;
}

::v-deep {
  .el-input__inner {
    padding: 0 8px;
  }
}
</style>
